#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

class Solution {
    public:
    vector<vector<int> > generateMatrix(int n) {
	vector<vector<int> > mat(n, vector<int>(n, 0));
        int left = 0, right = n-1, top = 0, down = n-1, id = 1;
	while (left <= right && top <= down) {
	    for (int i = left; i <= right; i++) 
		mat[top][i] = id++;
	    for (int i = top+1; i <= down; i++)
		mat[i][right] = id++;
	    for (int i = right-1; i >= left; i--)
		mat[down][i] = id++;
	    for (int i = down-1; i> top; i--)
		mat[i][left] = id++;
	    left++;
	    right--;
	    top++;
	    down--;
	}
	return mat;
    }
};

//test on 1337 online test and pass all the test
int main(int argc, char **argv)
{
    Solution mySolution;
    cout << "-----------------Test 1--------------------" << endl;
    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
